1. Start HTTP interface
Before calling the interface, we must open LEVEL hotel lock management software and click the "Open Interface" button, which will start LEVEL http interface.
Note: When opening the HTTP interface for the first time, the windows system will ask if network resources are allowed to be used. Please click "Allow to use". 
    1-1.Error log of http is in temp file. 
    1-2.Please click View certificate from menu "Hotel Layout Setting" -> System parameter setting to find http communication certificate and use it when calling below functions. 
    Note: the HTTP communication certificate used in the following example is  3FD9CA333C096B08 
    1-3. When the option "Using Keys in the HTTP interface" is checked in the "System Parameters" and the parameter "AES encryption is required when encrypted transmission is enabled" is specified in the following parameters, please decrypt the incoming parameters using AES.
	If you want to test AES encryption, please find 'AES_Semo. exe' to test the encryption parameters


2. Test HTTP interface is activated or not.
    2-1. Put one card on Encoder. 
    2-2. Open web browser, input "http://localhost:6868/CardID?cer=HTTP communication" and press "Enter" key. This is function of ReadCardID, the return data of this function will be returned in JSON format. 
    2-3. If success, you will get {"code":"0","CardID":"FE22074C"} in browser. "code" means return result,0 means success, others means failed. CardID is card ID number you get. 
    2-4. If failed, you will get {"code":"80","Msg":"no Encoder connected or no card on Encoder"} in browser. "Msg" is error explanation. 
    2-5. http://localhost:6868/CardID?cer=3FD9CA333C096B08 is http command, can use get or post method to call. If it is C#, get method is recommended


3. Function of ReadCardID: "http://localhost:6868/CardID"
    3-1. Parameters passed 
           cer=HTTP Communication certificate
    3-2. If call it successful, correct return data should be: {"code":"0","CardID":"FE22074C"}

4.Function of ReadCard: "http://localhost:6868/ReadCard
    4-1. Parameters passed
           cer=HTTP Communication certificate
           InfoType=JSON          
   When you want cardinfo to return to JSON format, please add infotype = JSON. This parameter is only valid for guest cards, and non guest cards will not return JSON

   Example of displaying JSON format:            http://localhost:6868/ReadCard?cer=AA1CD557EADD4436&InfoType=JSON
   Example of not displaying JSON format:      http://localhost:6868/ReadCard?cer=AA1CD557EADD4436&InfoType=string
    4-2. If call it successfully, correct return data (not JSON ) should be: 
       {"code":"0","CardInfo":"CardID:FE22074C Holder: CardType: Guest card RoomName: 001 SuiteNo.:1,2,3, BeginTime: 2019/9/28 Saturday 17:03:00 EndTime: 2019/9/29 Sunday 13:30:00 Available PubDoor:p1,p2,p3, ","CardType":"255"}."code" means return result, "CardInfo" is content of the card, "CardType" is the card type.  

    4-3. If call it successfully, correct return data (JSON ) should be: 
    {"code":"0",
    "CardInfo":
      {"CardType":15, 
      "CardID":"AA5A7AC5", 
      "BeginTime":[20,8,16,16,18],             //Note: the time format is [year, month, day, hour, minute]
      "EndTime":[20,8,17,12,30], 
      "BuildingName":"A", "FloorName":"2F", "RoomName":"204", "AreaID":0, "BuildingID":1, "FloorID":2, "RoomID":4, "Suite":[], 
      "PubDoorName":[p1,p2,p3], "PubDoorID":[1,2,3], 
      "OpenDeadBolt":true, "AirCondition":true, "Coffer":false, "Replace":true, 
      "ExtendBeginTime1":[20,8,16,16,18], "ExtendBuildingName1":"A", "ExtendFloorName1":"2F", "ExtendRoomName1":"205", 
      "ExtendAreaID1":1, "ExtendBuildingID1":1, "ExtendFloorID1":2, "ExtendRoomID1":5, "ExtendSuite1":[], 
      "ExtendOpenDeadBolt1":true, "ExtendAirCondition1":true, "ExtendCoffer1":false, "ExtendReplace1":true, 
      "ExtendBeginTime2":[20,8,16,16,18], "ExtendBuildingName2":"A", "ExtendFloorName2":"2F", "ExtendRoomName2":"206", 
      "ExtendAreaID2":1, "ExtendBuildingID2":1, "ExtendFloorID2":2, "ExtendRoomID2":6, "ExtendSuite2":[], 
      "ExtendOpenDeadBolt2":true, "ExtendAirCondition2":true, "ExtendCoffer2":false, "ExtendReplace2":true, 
      "ExtendGuestRoomAmount":2,       //Note: This is the number of extended rooms in one card. If extendguestroomamount = 0, there is no extended room data above
      "LiftID1":1, "LiftName1":"Lift1", "AccessibleFloors1":[2,3,4], 
      "LiftAmount":1,                              //Note: This is the number of elevators that can be opened. If the elevator function is not enabled, the elevator data will not appear
      "CardHolder":"20200816164821"} ,
    "CardType":"15"}

Card type and its corresponding data. 
0	Authorized Card
1	Clock Card
2	Installation Card
3	Spare Card
4	Data Card
5	Check-out Card
6	Stop Card
7	Report Lost Card
8	Meeting Card
9	Emergency Card
10	Master Card
11	Front gate Card
12	Area Card
13	Building Card
14	Floor Card
15	Guest Card
16      Visitor Card
17	Power Card
24	Wireless Device
254	Invalid Card
255	Blank Card

5. Function of IssueGuestCard: "http://localhost:6868/GuestCard"
    5-1. Parameters passed  
      1,cer=HTTP Communication certificate
      2,room=203                                     Room name, For example Room 203
      3,BeginTime=2019-08-26 12:00:00    Begin time, format is: yyyy-mm-dd hh:mm:ss
      4,EndTime=2019-08-27 12:00:00      End time, format is: yyyy-mm-dd hh:mm:ss
      5,CheckInMode=new                      New means new check-in,  follow means copy the last check-in
      6,GuestName=aaaaaa                     Guest name, it is not a necessary parameter, can choose to pass or not
      7,IDCardType=IDCard                     Type of credentialsit is not a necessary parameter, can choose to pass or not
      8,IDCardNO=123455678                 Credentials numberit is not a necessary parameter, can choose to pass or not
      9,deadbolt=1                                  Whether can open deadbolt:  1  able       0  disable
      10,AirCondition=1                            Whether can use air-conditioner:  1  able       0  disable
      11,suite=1,2,8                             The suites that can be opened. If the room is suite, can add this parameter. Maximal 8 suites, from 1 to 8. Suite=1,2,3,4,5,6,7,8 means all the 8 suites can be opened. If the room is not a suite, don't need write this parameter. 
      12,PubDoor=p1,p2,p3                 The public doors that can be opened. p1,p2,p3 is name of public door, use , to separate. If no need to open public door, no need write this parameter. 
      13,lift=1,5,6,7,2,0,2,8                   The elevator control reader that can be opened. Format is: "Lift No.1, Floor No.1, Floor No.2, Floor No.3". Maximal 20 data groups like this. Use "," to separate.
                        Note: when "floor No. 1" = 0, floor No. 2 and floor No. 3 represent continuous floors that can be opened. "Lift No." is "Elevator Controller No", can be set in menu "Hotel Layout Setting" -> "Elevator Controller setting". "Floor No." is "Floor No.", can be set in menu "Hotel Layout Setting" -> ""Room Setting" 
                        Note: The same Elevator Controller No. can be set for different devices. If no need to use Elevator controller, no need write this parameter.  
               Special case of lift parameter:
               lift=all means that all floors of all elevator controllers can be opened
               lift=-1,1,2,3 when the first value is -1, the following three values represent the elevator equipment number, 
                                  and  lift=-1,1,2,3  indicate that all floors of the three elevators with elevator equipment No. 1, 2, 3 can be opened    
      14,limitLiftTime = 1 limit time when using elevator: 1: limit time 0: unnecessary parameter without time limit, you can choose whether to pass the parameter or not
      15,ChannelMode= 1 whether to enable the channel mode (the door lock will become normally open after opening the door) 1: enabled 0: not enabled (default) unnecessary parameter, you can choose whether to transfer this parameter
      16. DeleteOldBLEKey = no   whether to delete the previous Bluetooth key of the room     yes: delete       No: do not delete        
                  It is not a necessary parameter, you can choose whether to transfer it. The default value is yes
                  Note: when checkinmode = follow, the deleteoldblekey parameter is invalid, and the system will not delete the issued Bluetooth key
	17. BreakfastTickets=1       The number of breakfast tickets is not a necessary parameter, you can choose whether to pass this parameter or not

    5-2. Demo in browser:
        http://localhost:6868/GuestCard?cer=3FD9CA333C096B08&room=102&PubDoor=p1,p2,p3&lift=1,5,6,7,2,2,3,1&BeginTime=2019-09-25 12:00:00&EndTime=2019-09-27 12:00:00&CheckInMode=new&BreakfastTickets=1
    5-3. Return data should be: {"code":"0","CardID":"FE22074C"}. "code" means return result,0 means success, others means failed. CardID is Guest cards ID number. 

    5.1 When use function of one guest card open multiple rooms, before write data for extension rooms, please firstly call function: http://localhost:6868/BeginSetGuestCardExtData
          5.1-1 Parameters passed      cer=HTTP communication certificate
          5.1-2 Return data should be: {"code":"0"}

    5.2 When use function of one guest card open multiple rooms, function of write data for extension rooms is: http://localhost:6868/SetGuestCardExtData
         5.2-1 Parameters passed 
                 cer=HTTP communication certificate
                 room=203                        Room name, For example Room 203
                 BeginTime=2019-08-26 12:00:00   Begin time, format is: yyyy-mm-dd hh:mm:ss
                 deadbolt=1                      Whether can open deadbolt:  1  able       0  disable
                 AirCondition=1                  Whether can use air-conditioner:  1  able       0  disable
                 suite=1,2,8                     The suites that can be opened. If the room is suite, can add this parameter. Maximal 8 suites, from 1 to 8. suite=1,2,3,4,5,6,7,8 means all the 8 suites can be opened. If the room is not a suite, don't need write this parameter. 
                 SequenceNO=1                    The extension rooms number, from 1 to 6. Note: when opened one sector in Guest Card Extension Sector 1, can add 3 extension rooms. When opened one more sector in Guest Card Extension Sector 2, can add another 3 extension rooms more. 
         5.2-2  Return data should be: {"code":"0"}
         5.2-3  Demo in browser:
         http://localhost:6868/BeginSetGuestCardExtData?cer=3FD9CA333C096B08
         http://localhost:6868/SetGuestCardExtData?cer=3FD9CA333C096B08&room=203&BeginTime=2019-10-27 12:00:00&SequenceNO=1
         ... ... ...
         http://localhost:6868/SetGuestCardExtData?cer=3FD9CA333C096B08&room=208&BeginTime=2019-10-27 12:00:00&SequenceNO=6
         http://localhost:6868/GuestCard?cer=3FD9CA333C096B08&room=202&BeginTime=2019-10-27 12:00:00&EndTime=2019-10-28 12:00:00&CheckInMode=new

6 Making Bluetooth key  http://localhost:6868/GuestCardBluetooth
    6-1   Parameters passed 
        1cer=HTTP communication certificate
        2. room = 203 room name,        AES encryption is required when encrypted transmission is enabled
        3. BeginTime= 2019-08-26 12:00:00 start time, the time format is yyyy MM DD HH: mm: SS      encryption is required when encryption transmission is enabled
        4. EndTime = 2019-08-27 12:00:00 end time, the time format is yyyy MM DD HH: mm: SS         encryption is required when encryption transmission is enabled
        5. CheckInMode = new     check in mode: "new" means new check-in and "follow" means follow-up check-in
        6. GuestName = aaaaaaaa guest name, which is not a necessary parameter. You can choose whether to transfer this parameter. AES encryption is required when encryption transmission is enabled
        7. IDCardType = ID card type, which is not a necessary parameter. You can choose whether to transfer this parameter. AES encryption is required when encryption transmission is enabled
        8. IDCardNO = 123455678 ID No. is not a necessary parameter. You can choose whether to transmit this parameter. AES encryption is required when encryption transmission is enabled
        9. deadbolt= 1 whether the anti lock can be opened: 1 can open the reverse lock, 0 can not open the reverse lock (default) unnecessary parameter, you can choose whether to transfer this parameter
        10. AirCondition= 1 whether air conditioning can be used: 1 can use air conditioning (default) 0 can not use air conditioning unnecessary parameters, you can choose whether to transfer this parameter
        11. handsFreeState= 1 whether to enable automatic door opening with Bluetooth key 1: enable 0: do not enable (default) unnecessary parameter, you can choose whether to transfer this parameter
        12. semiHandsFreeState= 1 whether to enable semi-automatic door opening with Bluetooth key 1: enable 0: do not enable (default) unnecessary parameter, you can choose whether to transfer this parameter
        13. ChannelMode= 1 whether to enable the channel mode (the door lock will become normally open after opening the door) 1: enabled 0: not enabled (default) unnecessary parameter, you can choose whether to transfer this parameter
        14. Suite = 1,2,8 suite number that can be opened. If the room is a suite, this parameter can be added. Suite number 1 to 8, suite = 1,2,3,4,5,6,7,8 means that all suites can be opened. If it is not a suite, this parameter can not be written, and AES encryption is required when encryption transmission is enabled
        15. Pubdoor = P1, P2, P3 the public doors that can be opened P1, P2, P3 are the names of public doors separated by ",". If it is not necessary to open the public door, this parameter can not be written, and AES encryption is required when encryption transmission is enabled
        16  EMailAddr=aaa@bbb.com     AES encryption is required when encrypted transmission is enabled for the mailbox receiving Bluetooth key
        17phone=13333333333      AES encryption is required when encrypted transmission is enabled for the telephone number receiving Bluetooth key
        18. DeleteOldBLEKey = no   whether to delete the previous Bluetooth key of the room     yes: delete       No: do not delete        AES encryption is required when encrypted transmission is enabled
                  It is not a necessary parameter, you can choose whether to transfer it. The default value is yes
                  Note: when checkinmode = follow, the deleteoldblekey parameter is invalid, and the system will not delete the issued Bluetooth key                  

        Note: if email is selected to receive the Bluetooth key in the system settings, enter the email addr parameter instead of the phone parameter, and vice versa
    6-2 Examples of debugging in the browser (field is not encrypted):
        Example of receiving Bluetooth key by email
        http://localhost:6868/GuestCardBluetooth?cer=3FD9CA333C096B08&EMailAddr=aaa@bbb.com&room=102&PubDoor=p1,p2,p3&BeginTime=2019-09-25 12:00:00&EndTime=2019-09-27 12:00:00&CheckInMode=new
        Example of receiving Bluetooth key with mobile phone
        http://localhost:6868/GuestCardBluetooth?cer=3FD9CA333C096B08&phone=18025989359&room=102&PubDoor=p1,p2,p3&BeginTime=2019-09-25 12:00:00&EndTime=2019-09-27 12:00:00&CheckInMode=new
    
    6-3  Return data should be: {"code":"0","CardID":"FE22074C"}. "code" means return result,0 means success, others means failed. CardID is Guest cards ID number. 
    6-4When "use key in HTTP interface" is enabled in "system parameter settings", the content of the parameter marked "AES encryption is required when enabling encrypted transmission" needs to be encrypted with AES algorithm.
            AES uses the encryption mode of ECB, the filling mode of pkcs7padding, blocksize = 16, the keybit is kb128, and the output mode is hexadecimal.
            The encrypted AES key can be input by using the input box on the right of the key in "system parameter settings" - > "HTTP interface"
            AES is found in the same directory of this document_ Demo.exe Examples of encrypted files can be provided as follows:
            http://localhost:6868/GuestCardBluetooth?cer=AA1CD557EADD4436&EMailAddr=179C2998483DD96160D43CBD3307A696&room=273F11AAC676811D8DB0C93C20BE2A91&BeginTime=3E6548D636FCC145CCDDE0AFD35AD8A6C64B8695BD8E6877722FAA15DEDE1225&EndTime=F153D8A1CBFCB52BB8281B834E8C715BC64B8695BD8E6877722FAA15DEDE1225&CheckInMode=new

7. Issue GuestCard by hotel lock software Interface : http://localhost:6868/GuestCardForm
    Note: when the hotel management software has no definition of the public door or elevator controller, there is no way to input the parameters of the public door or 
             elevator controller. In this case, you can use the "GuestCardForm" function, then the guest card issuing interface of the hotel lock software software will appear. 
            At this time, as long as you input the room number and time, other parameters do not need to be input
    7-1. Parameters passed  
       1,cer=HTTP Communication certificate
       2,room=101                                     Room name, For example Room 101
       3,BeginTime=2019-08-26 12:00:00    Begin time, format is: yyyy-mm-dd hh:mm:ss
       4,EndTime=2019-08-27 12:00:00      End time, format is: yyyy-mm-dd hh:mm:ss
       5,CheckInMode=new                      New means new check-in,  follow means copy the last check-in
       6,Autoissue=0                                 whether to issue card automatically.    0: indicates that card will not be issued automatically. 1: indicates that automatic card issuance 
                                                               Automatic card issuance is not recommended, and card reading and writing errors may occur
       7.DeleteOldBLEKey = no   whether to delete the previous Bluetooth key of the room     yes: delete       No: do not delete      
                  It is not a necessary parameter, you can choose whether to transfer it. The default value is yes
                  Note: when checkinmode = follow, the deleteoldblekey parameter is invalid, and the system will not delete the issued Bluetooth key      

    7-2. Demo in browser:
      http://localhost:6868/GuestCardForm?cer=AA1CD557EADD4436&room=101&BeginTime=2020-10-12 12:00:00&EndTime=2020-10-13 12:00:00&CheckInMode=new
    7-3. Return data should be: {"code":"0","CardID":"FE22074C"}. "code" means return result,0 means success, others means failed. CardID is Guest cards ID number. 

8. Function of Clear card/ Issue Blank card/ Check-out: http://localhost:6868/BlankCard
    Parameters passed 
    cer=HTTP communication certificate
    If call it successfully, correct return data should be: For example, {"code":"0","CardID":"FE22074C"}, "code" means return result,0 means success, others means failed. CardID is Blank cards ID number. 

8.1 Function of Checkout without card: http://localhost:6868/CheckOut
     8.1-1 Parameters passed 
                 cer=HTTP communication certificate
                 room=203     Room name, For example Room 203     AES encryption is required to enable encrypted transmission
                 BLEKeyID=00000051 Bluetooth key number. It is a fixed 8-bit string. AES encryption is required when encrypted transmission is enabled
                 Note: room and blekeyid parameters will not appear at the same time. If there is room parameter, blekeyid parameter will be ignored
     8.1-2: Demo in browser: http://localhost:6868/CheckOut?cer=3FD9CA333C096B08&room=203
     8.1-3: examples of debugging in browsers are (for example, clearing a Bluetooth key): http://localhost:6868/CheckOut?cer=3FD9CA333C096B08&BLEKeyID=00000051
     8.1-4: Return data should be: {"code":"0","Msg":"Checkout without card operate successfully"}  "code" means return result,0 means success, others means failed.

9. Function of Write MF1 card through LEVEL Encoder: http://localhost:6868/WriteData
    9-1. Parameters passed
        cer=HTTP communication certificate
        data=100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000   Write data, transfer 48 byte to 16 binary system string.
        key=FFFFFFFFFFFF    Key of sector, transfer 6 byte to 16 binary system string.
        sector=12           Sector to write, Sector 1 to 15 is available. 
    9-2: Demo in browser: http://localhost:6868/WriteData?
          cer=3FD9CA333C096B08&data=100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000&key=FFFFFFFFFFFF&sector=12
    9-3: Return data should be:  {"code":"0","Msg":"write data successfully"}


10. Function of Read MF1 card through LEVEL Encoder: http://localhost:6868/ReadData
     10-1. Parameters passed
         cer=HTTP communication certificate
         key=FFFFFFFFFFFF   Key of sector, transfer 6 byte to 16 binary system string.
         sector=12          Sector to read, Sector 1 to 15 is available. 
      10-2.Demo in browser: http://localhost:6868/ReadData?cer=3FD9CA333C096B08&key=FFFFFFFFFFFF&sector=12
      10-3. Return data should be: {"code":"0","Data":"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}  Data is return data, which is 16 binary system string after transferred from 48 byte. 


11. Function of Modify key of MF1 card through LEVEL Encoder: http://localhost:6868/WriteKey
     10-1 Parameters passed
       cer=HTTP communication certificate
       OldKey=FFFFFFFFFFFF     Old key of Sector, transfer 6 byte to 16 binary system string.
       NewKey=FFFFFFFFFFFF     New key of Sector, transfer 6 byte to 16 binary system string.
       sector=12               Sector to modify the key, Sector 1 to 15 is available.
    11-2 Demo in browser: http://localhost:6868/WriteKey?cer=3FD9CA333C096B08&OldKey=FFFFFFFFFFFF&NewKey=FFFFFFFFFFFF&sector=12
    11-3. Return data should be: {"code":"0","Msg":"modify key of sector successfully"}  


12. Function of Control automatic card-issuing machine: http://localhost:6868/IssueComplete
     12-1. Parameters passed
          cer=HTTP communication certificate
         IsSucceed=0  Send card to recycle house
         IsSucceed=1  Send card to card-taking positioncard-dropping position 
     12-2. Return data should be: {"code":"0","Msg":"Operate successfully"}

13.Function of Check card position in automatic card-issuing machine: http://localhost:6868/CheckCardPlace
     Parameters passed
     cer=HTTP communication certificate
     Return data should be: {"code":"0","CardStatus":"0"}
    CardStatus data:
   // 0x00  correct position (There are cards in the sensing area)
   // 0x01  incorrect position
   // 0x02  cards used out, card house is empty
   // 0x03  recycle house is full

14. Control the buzzer of Encoder. 
http://localhost:6868/BeepOk?cer=3FD9CA333C096B08
http://localhost:6868/BeepFailure?cer=3FD9CA333C096B08
http://localhost:6868/BeepAlarm?cer=3FD9CA333C096B08

15. Query the status of Bluetooth key http://localhost:6868/GetBLEKeyState
      15-1. Parameters transferred
             CER = HTTP communication certificate
             BLEKeyID={"idArr":["00000051","00000052"]}  Bluetooth key number list, the type of which is arrayobject, is an 8-bit string array. 
                              AES encryption is required when encrypted transmission is enabled
      15-2: examples of debugging in browser : http://localhost:6868/GetBLEKeyState?cer=3FD9CA333C096B08&BLEKeyID={"idArr":["00000051","00000052"]} 
      15-3: return result of obtaining Bluetooth key with email address:
          {"code":"0","dataList":[{"lastOpenTime":"","autoVendingState":0,"kid":51,"state":0,"autoVendingDate":0,"pauseState":0,"lastOpenDoorName":""},{"lastOpenTime":"","autoVendingState":0,"kid":52,"state":0,"autoVendingDate":0,"pauseState":0,"lastOpenDoorName":""}]} 
          15-3-1: "code" is the return value of the function
          15-3-2: dataList  is the JSON object array that arrayobject returns information such as key ID and its status. The structure of JSON object is as follows
                name	type	explain
                kid	number	ID of the key
                state	number	Key status 0: does not exist      1: not obtained        10: obtained
                lastOpenTime	String	The last opening time of the key, format:yyyyMMddHHmmss
                lastOpenDoorName	String	Name of the door lock of the last door opened by the key
                pauseState	number	0: active state    10: suspended state
                autoVendingState	number	0: do not automatically activate the key     10: automatically activate the key
                autoVendingDate	number	The number of milliseconds from 1970-01-01 00:00:00 UTC time can be automatically converted to the time in the current 
                                                                      time zone according to this number.                0: is not set

      15-4: return result of obtaining Bluetooth key with phone number: 
               {"code":"0","dataList":[{"kid":51,"state":0},{"kid":52,"state":0}]}    
          15-4-1:  "code" is the return value of the function
          15-4-2: dataList  is the JSON object array that arrayobject returns information such as key ID and its status. The structure of JSON object is as follows
               name	type	explain
               kid	number	ID of the key
               state	number	Key status 0: does not exist 1: not obtained 10: obtained

16. Issue Password key:   http://localhost:6868/GuestCardPassword
     16-1. Parameters transferred
            1. CER = HTTP communication certificate
            2. Room = Room 203 name. For example, AES encryption is required when encrypted transmission is enabled in Room 203
            3. Begintime = 2019-08-26 12:00:00 start time. The time format is yyyy MM DD HH: mm: SS. AES encryption is required when encrypted transmission is enabled
            4. Endtime = 2019-08-27 12:00:00 end time. The time format is yyyy MM DD HH: mm: SS. AES encryption is required when encrypted transmission is enabled
            5. Checkinmode = new check-in mode: new means new check-in, and follow means follow-up check-in
            6. Guestname = aaaaaa guest name, which is a non essential parameter. You can choose whether to transmit this parameter. AES encryption is required when encrypted transmission is enabled
            7. IdCardType = ID card type, which is a non essential parameter. You can choose whether to transmit this parameter. AES encryption is required when encrypted transmission is enabled
            8. IdCardNO = 123455678 ID number, which is an unnecessary parameter. You can choose whether to transmit this parameter. AES encryption is required when encryption transmission is enabled
            9. Suite = 1,2,8 suite number that can be opened. If the room is a suite, this parameter can be added. Suite number 1 to 8, suite = 1,2,3,4,5,6,7,8 means that all suites can be opened. If it is not a suite, this parameter can not be written, and AES encryption is required when encryption transmission is enabled
            10. DeleteOldBLEKey = no   whether to delete the previous Bluetooth key of the room     yes: delete       No: do not delete        AES encryption is required when encrypted transmission is enabled
                  It is not a necessary parameter, you can choose whether to transfer it. The default value is yes
                  Note: when checkinmode = follow, the deleteoldblekey parameter is invalid, and the system will not delete the issued Bluetooth key   
   
      16-2: an example of debugging in the browser (field is not encrypted):
          http://localhost:6868/GuestCardPassword?cer=AA1CD557EADD4436&room=102&BeginTime=2021-12-18 12:00:00&EndTime=2021-12-19 12:00:00&CheckInMode=new
      16-3: the returned results are as follows: {"code": "0", "passwordkey": "23082390283"} where code is the return value of the function, passwordkey is the password key of the room door, and the password key is 11 digits
               When there is a suite, it will return: {"code": "0", "passwordkey": "23082390283", "suitekey1": "10455931487", "suitekey2": "10455931487",..., "suitekey8": "53455370348"}
               Where code is the return value of the function, passwordkey is the password key of the room door, suitekey1 to suitekey8 are the password keys from Suite 1 to Suite 8, and the password key is 11 digits
       16-4: when "use key in HTTP interface" is enabled in "system parameter settings", the content of the parameter marked "AES encryption is required when enabling encrypted transmission" needs to be encrypted with AES algorithm.
                The encryption mode used by AES is ECB, the filling mode is pkcs7padding, blocksize = 16, keybit is kb128, and the output mode is hexadecimal.
                The encrypted AES key can be entered in the input box on the right of "key" in "system parameter settings" - > "HTTP interface"

17. Make replacement password for password key : http://localhost:6868/ReplacePasswordKey 
     17-1. Parameters transferred
           1. CER = HTTP communication certificate
           2. PasswordKey=23082390283 password key, 11 digits. AES encryption is required when enabling encrypted transmission
     17-2: an example of debugging in the browser (field is not encrypted):
          http://localhost:6868/ReplacePasswordKey?cer=AA1CD557EADD4436&PasswordKey=23082390283  
     17-3: the returned results are as follows: {"code": "0", "replacepasswordkey": "21713332601"} where code is the return value of the function, replacepasswordkey is the replacement password of the entered password key, and the replacement password is 11 digits
     17-4: when "use key in HTTP interface" is enabled in "system parameter settings", the content of the parameter marked "AES encryption is required when enabling encrypted transmission" needs to be encrypted with AES algorithm.
              The encryption mode used by AES is ECB, the filling mode is pkcs7padding, blocksize = 16, keybit is kb128, and the output mode is hexadecimal.
              The encrypted AES key can be entered in the input box on the right of "key" in "system parameter settings" - > "HTTP interface"

18. Pause BLEkey http://localhost:6868/EditBLEKeyState
     18-1 Transferred parameters
         cer=HTTP communication voucher
         action=pause action. You can only enter pause, vend, autoChangeKeyStatus, stopAutoChangeKeyStatus. AES encryption is required when enabling encrypted transmission
         BLEKeyID=00000051 Bluetooth key number, a character string with a fixed length of 8 bits. AES encryption is required when encryption transmission is enabled
         autoVendingDate=1000 only takes effect when action=autoChangeKeyStatus The number of milliseconds (converted into string) after the time of automatically changing the key status is converted to UTC time zone time and the difference between the UTC time 1970-1-1 00:00:00 requires AES encryption when encryption transmission is enabled
     18-2: Example of debugging in browser (pause key): http://localhost:6868/EditBLEKeyState?cer=3FD9CA333C096B08&action=pause&BLEKeyID=00000051
     18-3: Example of debugging in browser (activation key): http://localhost:6868/EditBLEKeyState?cer=3FD9CA333C096B08&action=vend&BLEKeyID=00000051
     18-4: Example of debugging in browser (automatically changing key status): http://localhost:6868/EditBLEKeyState?cer=3FD9CA333C096B08&action=autoChangeKeyStatus&BLEKeyID=00000051&autoVendingDate=1000
     18-5: Examples of debugging in the browser, such as (canceling the automatic change of key status): http://localhost:6868/EditBLEKeyState?cer=3FD9CA333C096B08&action=stopAutoChangeKeyStatus&BLEKeyID=00000051
     18-6: The returned result is as follows: {"code": "0", "Msg": "Operation succeeded"} where code is the function return value


19. Unbind the user's mobile phone http://localhost:6868/unlockHotelUserPhone
     19-1. Transferred parameters
         cer=HTTP communication voucher
         emailAddress= abc@123.com EMail address, AES encryption is required when encryption transmission is enabled
     19-2: Example of debugging in browser: http://localhost:6868/unlockHotelUserPhone?cer=3FD9CA333C096B08&emailAddress=abc @123.com
     19-3: The returned result is as follows: {"code": "0", "Msg": "Operation succeeded"} where code is the function return value


20. Obtain the top 200 door opening records sorted in ascending order by insertion time http://localhost:6868/obtainTwoHundredKeyOpenRecords
     20-1. Transferred parameters
           Cer=HTTP communication credential
     20-2: Examples of debugging in the browser are as follows: http://localhost:6868/obtainTwoHundredKeyOpenRecords?cer=3FD9CA333C096B08
     20-3: The returned result is as follows:
           Read failure: {"code": "255", "Msg": "failure reason"} where code is the function return value
When obtaining Bluetooth keys using EMail
Successfully read (AES encryption enabled): {"code": "0", "dataList": ["...", "...", "...."]}
Successfully read (without AES encryption enabled): {"code": "0", "dataList": [{...}, {...}, {...}]}
dataList is ArrayObject
The object structure of dataList
Attribute Name 	Type 	Description
koid		number	ID of the door opening record
kid		number	BLE Key ID
emailAddress	String	e-mail address
hotelName	String	Hotel Name
hotelCode	String	Hotel number
roomName	String	Door lock name
cardType	number	Card Type
doorType	number	Door lock type
areaNum		number	area number
buildingNum	number	Building number
floorNum	number	Floor number
roomNum		number	Room No
suiteNum	number	Suite number
publicDoorNum	number	Public Door Number
lowPower	number	Low voltage prompt 0: Normal 1: Low voltage
doorInstallInfo	String	
openTime	String	yyyyMMddHHmmss

When obtaining the Bluetooth key using the phone number, successfully read: {"result": "0", "dataList": [{...}, {...}, {...}], "count": 10} 
dataList is ArrayObject and "count" is the number of returned records
The object structure of dataList
Attribute Name 	Type 	Description
koid		number	ID of the door opening record
kid		number	BLE Key ID
currUserName	String	User name for opening the door (WeChat nickname)
doorName	String	Door lock name
cardType	number	Card Type
doorType	number	Door lock type
areaNum		number	area number
buildingNum	number	Building number
floorNum	number	Floor number
roomNum		number	Room No
suiteNum	number	Suite number
publicDoorNum	number	Public Door Number
devID		String	
lowPower	number	Low voltage prompt 0: Normal 1: Low voltage
cardNum		String	Card number
openTime	String	yyyyMMddHHmmss
battery		number	Battery level percentage, such as 90

21. Interface for obtaining door opening records (only retaining 2 months of data) http://localhost:6868/searchOpenRecords
	21-1. Parameters passed
		Cer=HTTP communication credential
		RoomName=203 Room name requires AES encryption when enabling encrypted transmission
		StartTime=20230702112233 Start time, format: yyyyMMddHHmmss AES encryption is required when enabling encrypted transmission
		EndTime=20230802112233 End time, format: yyyyMMddHHmmss AES encryption is required when enabling encrypted transmission
		PageNum=3 Which page is it
        21-2: Example of debugging in browser: http://localhost:6868/searchOpenRecords?cer=3FD9CA333C096B08&roomName=203&startTime=20230702112233&endTime=20230802112233&pageNum=3
	21-3: The returned result is as follows:
		Read failure: {"code": "255", "Msg": "failure reason"} where code is the function return value
When obtaining Bluetooth keys using EMail
Successfully read (AES encryption enabled): {"code": "0", "dataList": ["...", "...", "...."]}
Successfully read (without AES encryption enabled): {"code": "0", "dataList": [{...}, {...}, {...}]}
dataList is ArrayObject
The object structure of dataList
Attribute Name 	Type 	Description
koid		number	ID of the door opening record
kid		number	BLE Key ID
emailAddress	String	e-mail address
hotelName	String	Hotel Name
hotelCode	String	Hotel number
roomName	String	Door lock name
cardType	number	Card Type
doorType	number	Door lock type
areaNum		number	area number
buildingNum	number	Building number
floorNum	number	Floor number
roomNum		number	Room No
suiteNum	number	Suite number
publicDoorNum	number	Public Door Number
lowPower	number	Low voltage prompt 0: Normal 1: Low voltage
doorInstallInfo	String	
openTime	String	yyyyMMddHHmmss


22. Create guest cards      http://localhost:6868/GuestCardEx
       22-1. Passing Parameters        	1.data={"cer":"3FD9CA333C096B08","room":"203","BeginTime":"202405071200","EndTime":"202405081200","CheckInMode":"new","deadbolt":1,"AirCondition":1,"suite":[1,2,8],"PubDoor":["p1","p2","p3"],"lift":["lift1","5","6","8","lift2","0","2","8"],"ExtraRoom":[{"room":"204","suite":[1,2,3],"deadbolt":1,"AirCondition":1,"ChannelMode":0,"ReplaceState":1},{"room":"205","suite":[1,2],"deadbolt":1,"AirCondition":1,"ChannelMode":0,"ReplaceState":1}],"DeleteOldBLEKey":"no","LostCardID":"FE22074C","RoomRewrite":1,"PubDoorRewrite":0,"BreakfastTickets"=1}        It is a JSon format string, and AES encryption is required to enable encrypted transmission

            name				explain							data type
	1room     			Room Name								string
	2BeginTime      		start time						string 		format is  YYYYMMDDhhmm
      	3EndTime         		End time						string 		format is  YYYYMMDDhhmm  
        4CheckInMode     	Check-in mode					string 		"new" represents new check-in. 		"follow" represents following check-in
        5GuestName          	Guest Name						string      	Non essential parameter, you can choose whether to pass this parameter or not
        6IDCardType          	Document type 					string      	Non essential parameter, you can choose whether to pass this parameter or not
        7IDCardNO             	ID number						string      	Non essential parameter, you can choose whether to pass this parameter or not     
        8deadbolt               Can the reverse lock be opened	integer		1 can unlock and      0 cannot unlock (default)     
																	Non essential parameter, you can choose whether to pass this parameter or not
        9AirCondition         Can air conditioning be used		integer		1 can use air conditioning (default)            0 cannot use air conditioning        
																	Non essential parameter, you can choose whether to pass this parameter or not
        10ChannelMode       Is channel mode enabled			integer		After opening the door, the door lock will become normally open     
																	1: Enable           0: Do not enable (default)
      																	Non essential parameter, you can choose whether to pass this parameter or not
        11suite          		Available suite numbers			integer array  	If the room is a suite, this parameter can be added. Suite numbers 1 to 8 indicate that all suites can be opened
																		If it is not a suite, this parameter can be omitted     
        12PubDoor		Public doors						String array     If it is not necessary to open a public door, this parameter can be omitted     
	13lift				An elevator controller that can be operated				String array
						The parameter format is: "Elevator equipment name 1, floor number 1, floor number 2, floor number 3". 
						There can be 20 combinations, with each group of data separated by ",". For example:["lift1","5","6","8","lift2","0","2","8"]
						Note: When "floor number 1"="0", floor number 2 and floor number 3 represent consecutive floors that can be opened
                                    		"Elevator equipment name" can be found in the "Elevator Equipment Name" field in the elevator controller list of 
						"Hotel Settings" ->"Elevator Controller Settings" in the door lock management software
                                    		"Floor number" can be found in the "Hotel Settings" ->"Room Settings" room list in the door lock management software in the "Floor Number" field
                                      		Note: The name of the elevator equipment can be repeated. If the elevator equipment is not needed, this parameter can be omitted
              			Special case of lift parameter:
              			lift=["all"] Indicates that all floors of all elevator controllers can be opened
              			lift=["","lift1","lift2","lift3"]   When the first value is "", the following three values represent the elevator equipment name,  
				lift=["","lift1","lift2"] All floors of the two elevators with elevator equipment names "lift1" and "lift2" can be opened
              			lift=["","","lift1","lift10"]   When the first and second values are "", the following two values represent the elevator equipment name 
				lift=["","","lift1","lift10"] All floors of the 10 elevators with elevator equipment names from "lift1" to "lift10" can be opened 

	14limitLiftTime      	Is there a time limit when using the elevator        		integer        1: Limit time     0: No time limit    
																					Non essential parameter, you can choose whether to pass this parameter or not
	15ExtraRoom		Additional rooms when using one card to open multiple rooms		Json object array		
				Example of parameter format: {"room":"204","suite":[1,2,3],"deadbolt":1,"AirCondition":1,"ChannelMode":0,"ReplaceState":1}
				room     			Expand room name						string
				suite          		Available suite numbers					integer array  	If the room is a suite, you can add this parameter, suite numbers 1 to 8,   
																						Indicates that all suites can be opened. If it is not a suite, this parameter can be omitted
				deadbolt               Can the reverse lock be opened			integer		1 can unlock and    0 cannot unlock (default)      
																					Non essential parameter, you can choose whether to pass this parameter or not
				AirCondition         Can air conditioning be used				integer		1 can use air conditioning (default)       0 cannot use air conditioning        
																					Non essential parameter, you can choose whether to pass this parameter or not
				ChannelMode       Is channel mode enabled					integer		After opening the door, the door lock will become normally open. 
																					1: enabled.            0: not enabled (default)      
																					Non essential parameter, you can choose whether to pass this parameter or not
				ReplaceState	Whether to replace						integer		1: Replace (default) 0: Do not replace      
																					Non essential parameter, you can choose whether to pass this parameter or not

        16ReserveNumber     	Booking number								integer  		You can choose whether to pass this parameter or not
        17DeleteOldBLEKey   	Do you want to delete the previous Bluetooth key for this room    		string      Yes: delete no: do not delete   The default value is yes      
																					Non essential parameter, you can choose whether to pass this parameter or not
          	       																			Note: When CheckInMode=follow, the DeleteOldBLEKey parameter is invalid, 
																					and the system will not delete Bluetooth keys that have already been issued
        18LostCardID			Reported lost card number					string			You can choose whether to pass this parameter or not      
	19RoomRewrite     		Enable reverse writing of guest room records      integer			1: Enable 0: Do not enable (default) non essential parameters ,
																						You can choose whether to pass this parameter or not
   	20PubDoorRewrite		Enable public door reverse writing record      	integer			1: Enable 0: Do not enable (default) non essential parameters 
																						You can choose whether to pass this parameter or not	
	21BreakfastTickets		Number of breakfast tickets				      	integer			You can choose whether to pass this parameter or not
	
    22-2: Example of debugging in browser:
        http://localhost:6868/GuestCardEx?data={"cer":"3FD9CA333C096B08","room":"203","BeginTime":"202405071200","EndTime":"202405081200","CheckInMode":"new","deadbolt":1,"AirCondition":1,"suite":[1,2,8],"PubDoor":["p1","p2","p3"],"lift":["lift1","5","6","8","lift2","0","2","8"],"ExtraRoom":[{"room":"204","suite":[1,2,3],"deadbolt":1,"AirCondition":1,"ChannelMode":0,"ReplaceState":1},{"room":"205","suite":[1,2],"deadbolt":1,"AirCondition":1,"ChannelMode":0,"ReplaceState":1}],"DeleteOldBLEKey":"no","LostCardID":"FE22074C","RoomRewrite":1,"PubDoorRewrite":0,"BreakfastTickets"=1}

   22-3: The returned result is as follows:   {"code": "0","CardID":"FE22074C"} 


23. Card free check-out  http://localhost:6868/CheckOutEx
      23-1. Passing Parameters
           1. data={"cer":"3FD9CA333C096B08","room":["201","202","203"],"BLEKeyID":["00000051","00000052"]}   It is a JSon format string, and AES encryption is required to enable encrypted transmission
                 Data parameter description:
                    1. room    The room name. It is a string array
                    2. BLEKeyID  Bluetooth key number. It is a string array
            Note: The room and BLEKeyID parameters can exist simultaneously, allowing for the simultaneous processing of check-out rooms and deleting Bluetooth keys

       23-2: Example of debugging in browserhttp://localhost:6868/CheckOutEx?data={"cer":"3FD9CA333C096B08","room":["201","202","203"],"BLEKeyID":["00000051","00000052"]}
       23-3: The returned result is as follows{"code":"0","Msg":"Card free check-out operation successful"}    Where code is the return value of the function

24. Read the number of breakfast tickets   http://localhost:6868/ReadBreakfastTicket
       24-1. Transferred parameters  
            cer=HTTP communication credentials
  
       24-2: Examples of debugging in the browser are as followshttp://localhost:6868/ReadBreakfastTicket?cer=3FD9CA333C096B08
       24-3: The returned result is as follows {"code": "0","CardID":"FE22074C","BreakfastTickets":1}   Among them, CardID is the card number, and BreakfastTickets is the number of breakfast tickets in the card


25. Deduct one breakfast ticket    http://localhost:6868/UseBreakfastTicket
       25-1. Transferred parameters  
            cer=HTTP communication credentials
  
       25-2: Examples of debugging in the browser are as followshttp://localhost:6868/UseBreakfastTicket?cer=3FD9CA333C096B08
       25-3: The returned result is as follows {"code": "0","CardID":"FE22074C","BreakfastTickets":1}   Among them, CardID is the card number, and BreakfastTickets is the remaining number of breakfast tickets in the card


26. Modify the number of breakfast tickets   http://localhost:6868/EditBreakfastTicket
       26-1.Transferred parameters
            cer=HTTP communication credentials
            BreakfastTickets=1   If the function executes successfully, this is the number of breakfast tickets in the card
  
       26-2: Examples of debugging in the browser are as follows: http://localhost:6868/EditBreakfastTicket?cer=3FD9CA333C096B08&BreakfastTickets=3
       26-3: The returned result is as follows: {"code": "0","CardID":"FE22074C","BreakfastTickets":3}   Among them, CardID is the card number, and BreakfastTickets is the number of breakfast tickets in the card





Error explanation 
Error 12: No http communication certificate, or http communication certificate error, or card issuing parameters have format error (for example, Room No., Building No., or time format etc)

Error 29: Cannot find this card in card-holding list

Error 40: 'LIV_OPEN_DEVICE_FAILED';           Failed to open encryption device  
Error 41: 'LIV_FIND_DEVICE_FAILED';           Failed to locate encryption device  
Error 42: 'LIV_INVALID_PARAMETER';            Parameters format error 
Error 43: 'LIV_INVALID_BLOCK_NUMBER'          Read encryption datas address parameters error  
Error 44: 'LIV_HARDWARE_COMMUNICATE_ERROR';   Communication error 
Error 45: 'LIV_INVALID_PASSWORD';             Check encryption devices key error   
Error 46: 'LIV_ACCESS_DENIED';                Refused the application of pass encryption device   
Error 47: 'LIV_ALREADY_OPENED';               Opened encryption device already   
Error 48: 'LIV_ALLOCATE_MEMORY_FAILED';       Locate memory error  
Error 49: 'LIV_INVALID_UPDATE_PACKAGE';       The update packages data is invalid  
Error 50: 'LIV_SYN_ERROR';                    Synchronize data error      

Error 52: No room name

Error 60: Write data into Time device error      
Error 61: Read Time devices data error     
Error 62: CRC Check failure                
Error 63: Invalid Copy card, please use correct card from valid sources.  

Error 80: No Encoder connected, or no card on Encoder.      
Error 81: Failed to lock the card     
Error 82: Failed to choose card               
Error 83: Failed to check the key of card    
Error 84: Failed to write data into card         
Error 85: Failed to apply for Encoder upgrading      
Error 86: Failed to read card data         
Error 87: Current device is different from requested device  

Error 131: Failed to open DataSet
Error 133: Failed to carry out the command

Error 159: Cannot find the designated room data, or current operator does not have right to operate this room
Error 171: Carry out initialization action error
Error 193: Didnt open http interface function, please open lock management software and click "Open Interface" button.
Error 255: The room is not in Check-in status, or exceed the maximal quantity of guest card, or the room is in maintenance status and cannot check in.
Error 283: Service is in not started status 
Error 320: Failed to search card records
Error 322: Failed to add card records
Error 362: Card is reported lost


2001:Failed to connect to the Cloud, please restart the application.
                        
2004:Username must be an email address
                        
2013:The Mobile Keys settings are in correct, please contact TLJ Support
            
2014:The Hotel info is in correct, please contact TLJ Support
            
2015:The Hotel info is in correct, please contact TLJ Support
            
2016:The Hotel info is in correct, please contact TLJ Support
            
2017:Failed to upload the Mobile Key to the cloud, please check your connection. If the problem persists contact TLJ Support.
 
2020:Fail to obtain user info, please check connection.
            
2023:the key does not exist
            
2024:Fail to delete the key, check connection and try again.
            
2027:Time format error

2034:This user has been Frozen, please contact reception

2053:Software outdated, please update.


2056: Invalid access token

2058:Fail to explain parameters.

2060: the 3rd party interface is not existed

2061: fail to get 3rd party interface

2062: the 3rd part interface is under frozen status

2063: the operation is expired.

Update list:
1. In http://localhost : 6868 / guestcard added the limitLiftTime parameter
2. Change checkout to encrypt room parameter with AES



